package com.six.controller;

import com.six.entry.SysUser;
import com.six.service.SysUserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * Date:2022/12/10
 * Author：cjl
 */
@RequestMapping("/sysUser")
@RestController
public class SysUserLoginController {

    @Autowired
    private SysUserLoginService sysUserLoginService;

    @RequestMapping("/login")
    @ResponseBody
    public Map<String, String> userLogin(@RequestParam("username") String username,
                                         @RequestParam("password") String password,
                                         HttpServletRequest request) {

        SysUser sysUser = sysUserLoginService.queryUserByNameAndPassword(username, password);
        Map<String, String> result = new HashMap<String, String>();
        if (sysUser != null) {
            result.put("flag", "true");
        } else {
            result.put("flag", "false");
        }
        return result;
    }


}
